package me.blankm.wslib.request;

import com.google.gson.annotations.SerializedName;


/**
 * Author by Mr.Meng
 * created 2021/11/24
 *
 * @desc
 */
public class Request<T> {
    //当前事件
    @SerializedName("action")
    private String action;

    @SerializedName("seq_id")
    private long seqId;
    //请求参数
    @SerializedName("args")
    private T request;

    private transient int reqCount;



    public Request(String action, long seqId, T request, int reqCount) {
        this.action = action;
        this.seqId = seqId;
        this.request = request;
        this.reqCount = reqCount;
    }


    public String getAction() {
        return action;
    }


    public void setAction(String action) {
        this.action = action;
    }


    public long getSeqId() {
        return seqId;
    }


    public void setSeqId(long seqId) {
        this.seqId = seqId;
    }


    public T getReq() {
        return request;
    }


    public void setReq(T req) {
        this.request = req;
    }


    public int getReqCount() {
        return reqCount;
    }


    public void setReqCount(int reqCount) {
        this.reqCount = reqCount;
    }


    public static class Builder<T> {
        private String action;
        private long seqId;
        private T req;
        private int reqCount;

        public Builder action(String action) {
            this.action = action;
            return this;
        }

        public Builder seqId(long seqId) {
            this.seqId = seqId;
            return this;
        }


        public Builder reqArgs(T req) {
            this.req = req;
            return this;
        }


        public Builder reqCount(int reqCount) {
            this.reqCount = reqCount;
            return this;
        }

        public Request build() {
            return new Request<T>(action, seqId, req, reqCount);
        }

    }
}
